package com.caogen.cg_wl_kt.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.Adapter
import androidx.viewbinding.ViewBinding
import com.caogen.cg_wl_kt.R
import com.caogen.cg_wl_kt.base.Base2Adapter
import com.caogen.cg_wl_kt.base.BaseAdapter
import com.caogen.cg_wl_kt.base.BaseHolder
import com.caogen.cg_wl_kt.databinding.ItemHomeListBinding
import com.caogen.cg_wl_kt.model.home.HomeListBean
import com.caogen.cg_wl_kt.vmodel.fragment.HomeViewModel

/**
 * 项目名称: cg_wl_kt
 * Packages:com.caogen.cg_wl_kt.adapter
 * author: FSW
 * 创建日期: 2024/2/28 16:18
 * Describe:
 *
 */
open class HomeAdapter(context: Context) : Base2Adapter<HomeListBean, HomeAdapter.MyViewHolder>(context){
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
//        val view= LayoutInflater.from(parent.context).inflate(R.layout.item_home_list ,parent,false)
//        return MyViewHolder(view)
        val binding = ItemHomeListBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        return MyViewHolder(binding)
    }

    override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
        super.onBindViewHolder(holder, position)
        val news=dataList[position]
        holder.binding.textView.text =news.id
        holder.binding.textView2.text ="home2adapter"
        holder.binding.textView3.text =news.sub
//        holder.textView.text=news.id
//        holder.textView2.text="home2adapter"
//        holder.textView3.text=news.sub
    }
    //    class MyViewHolder(view: View) : RecyclerView.ViewHolder(view){
//        //        var textView:ImageView=view.findViewById(R.id.newPicture)
//        var textView: TextView =view.findViewById(R.id.textView)
//        var textView2: TextView =view.findViewById(R.id.textView2)
//        var textView3: TextView =view.findViewById(R.id.textView3)
//    }
    class MyViewHolder(val binding: ItemHomeListBinding) : RecyclerView.ViewHolder(binding.root)
}